package org.example.springioc.Controller;

//读取配置文件


import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController//让 Spring 能扫描到该类
public class propertiesController {
    //使用 @Value 来接收配置文件中的内容
//    @Value("${myKey.key1}")
//    private Integer key1;

    @Value("${string.value1}")
    private String stringValue1;

    @Value("${string.value2}")
    private String stringValue2;

    @Value("${string.value3}")
    private String stringValue3;

    @Value("${boolean.value1}")
    private Boolean booleanValue1;

    @Value("${boolean.value2}")
    private Boolean booleanValue2;

    @Value("${int.value}")
    private Integer intValue;

    @Value("${float.value}")
    private Float floatValue;

//    @Value("${null.value}")
//    private Object nullValue;

    @Value("${empty.value}")
    private String emptyValue;

    @RequestMapping("/getValue")
    public String getValue(){
        return "读取配置文件中的值为: " + stringValue3;
    }
}
